﻿<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!--#include file="../Include/Config.asp"-->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<%
'----------------------------------------------------------
'页面功能：系统管理页面，问卷信息查看和编辑。
'最后修改时间：2007-11-24 14时35分
'作者：legal http://www.ilegal.cn
'备注：
'----------------------------------------------------------
%>
<link rel="stylesheet" href="../Css/Admin.css" type="text/css" />
<script language="javascript" type="text/javascript" src="../Js/Date.js"></script>
<script language="javascript">
function CheckPassword(obj1,obj2,num){ //检查密码输入，obj1是密码检测对象1,obj2是密码检测对象2,num是合法密码位数
var Pass1=document.getElementById(obj1).value;
var Pass2=document.getElementById(obj2).value;
if(Pass1.length<num||Pass2.length<num){
alert("密码必须大于"+num+"位");
document.getElementById(obj1).focus();
return 0;
}else 
if(Pass1!=Pass2){
alert("两次密码输入不一致！");
Pass1.focus();
return 0;
}


}
function SwitchHidden(obj){
if (document.getElementById(obj).style.display=="none")
document.getElementById(obj).style.display="block";
else
document.getElementById(obj).style.display="none";
}

function AddIPAddress(){
var IPStart,IPEnd,i;
IPStart=document.getElementById("ipSta1").value+"."+document.getElementById("ipSta2").value+"."+document.getElementById("ipSta3").value+"."+document.getElementById("ipSta4").value;
IPEnd=document.getElementById("ipEnd1").value+"."+document.getElementById("ipEnd2").value+"."+document.getElementById("ipEnd3").value+"."+document.getElementById("ipEnd4").value;
var IPValue=IPStart+"---"+IPEnd;
selectedNum = document.getElementById('Survey_ipList').options.length;
for(i=0;i<=selectedNum-1;i++){                                     //检查重复添加
if(document.getElementById('Survey_ipList').options[i].value==IPValue){
alert("请IP范围已经存在,请不要重复添加");
return 0;
  }
}
document.getElementById('Survey_ipList').options[selectedNum]=document.createElement("option");
document.getElementById('Survey_ipList').options[selectedNum].text=IPValue;
document.getElementById('Survey_ipList').options[selectedNum].value=IPValue;
document.getElementById("ipSta1").value="";
document.getElementById("ipSta2").value="";
document.getElementById("ipSta3").value="";
document.getElementById("ipSta4").value="";
document.getElementById("ipEnd1").value="";
document.getElementById("ipEnd2").value="";
document.getElementById("ipEnd3").value="";
document.getElementById("ipEnd4").value="";
}
function DellSelected(){ //删除选中的IP范围段
	var flag = 0;
	var len = document.getElementById('Survey_ipList').options.length;
	for (i = 0; i < len; i++) {
		if(document.getElementById('Survey_ipList').options[i].selected){
		  flag = 1;
		  break;
		}
	}
	if (flag ==0){
	alert("请选择需要删除的IP范围段");
	return 0;
	}
	var index = document.getElementById('Survey_ipList').selectedIndex;
	while (index != -1) {
		document.getElementById('Survey_ipList').options[index] = null;
		
		index = document.getElementById('Survey_ipList').selectedIndex;
	}
	return 0;
}
function DellAll(){ //删除所有的IP范围段
	var len = document.getElementById('Survey_ipList').options.length;
		for (i = 0; i < len; i++) {
			document.getElementById('Survey_ipList').options[0] = null;			
		}
}

function CheckForm(){
    if(document.getElementById('Survey_name').value==""){
	alert("请输入问卷名称");
	return 0;
	}else if(document.getElementById('Survey_author').value==""){
	alert("请输入问卷发起人(单位)");
	//alert(document.getElementById('Survey_isPassword').value);
	return 0;
	}else{
	    var obj=document.getElementById("Survey_ipList");
		var ipStart=document.getElementById("Survey_ipStart");
		var ipEnd=document.getElementById("Survey_ipEnd");
		var ipStartValue="";
		var ipEndValue="";
		for(var i=0;i<obj.options.length;i++){
		   var ipvalue=obj.options[i].value;
		   ipvalue=ipvalue.split("---");
		   if(ipStartValue==""){
		       ipStartValue=ipvalue[0];
		   }else{
		       ipStartValue=ipStartValue+","+ipvalue[0];
		   }
		   if(ipEndValue==""){
		       ipEndValue=ipvalue[1];
		   }else{
		       ipEndValue=ipEndValue+","+ipvalue[1];
		   }
		  } 
    	ipStart.value=ipStartValue;
		ipEnd.value=ipEndValue;
		return true;
	}
}
</script>
<script>
function mask(obj,kind){
obj.value=obj.value.replace(/[^\d]/g,'')
key1=event.keyCode
if (key1==37 || key1==39)
{ obj.blur();
nextip=parseInt(obj.name.substr(5,1))
nextip=key1==37?nextip-1:nextip+1;
nextip=nextip>=5?1:nextip
nextip=nextip<=0?4:nextip
eval("var ip=document.getElementById('ip"+kind+""+nextip+"');")
eval("ip.focus();")
} 
if(obj.value.length>=3) 
if(parseInt(obj.value)>=256 || parseInt(obj.value)<=0)
{
alert(parseInt(obj.value)+"IP地址错误！")
obj.value=""
obj.focus()
return 0;
}
else 
{ obj.blur();
nextip=parseInt(obj.name.substr(5,1))+1
nextip=nextip>=5?1:nextip
nextip=nextip<=0?4:nextip
eval("var ip=document.getElementById('ip"+kind+""+nextip+"');")
eval("ip.focus();")
}
}
function mask_c(obj){
clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))
}

</script>
</head>
<body>
<div id="admin_surveyAdd_main">
<form name="from1" action="SurveyAddSave.asp?action=addSurvey" method="post" onSubmit="return CheckForm();">
<table width="585" border="0" cellspacing="0" cellpadding="0" class="table">
  <tr>
    <th>问卷添加</th>
    <th>&nbsp;</th>
    <th width="374"><span class="R">*</span> 为必填项目 </th>
  </tr>
  <tr>
    <td>问卷名称</td>
    <td><input name="Survey_name" type="text" size="50"></td>
    <td width="374"><span class="R">*</span> 问卷的名称，既问卷的总标题</td>
  </tr>
  <tr>
    <td>问卷发起人(单位)</td>
    <td><input name="Survey_author" type="text" size="50"></td>
    <td width="374"><span class="R">*</span> 问卷发起人，此问卷的所有单位</td>
  </tr>
  <tr>
    <td>问卷描述</td>
    <td><textarea rows="2" name="Survey_description" cols="60" onpropertychange="this.style.posHeight=this.scrollHeight"></textarea></td>
    <td> &nbsp;&nbsp;对此问卷的简单描述，这段描述将放在问卷前</td>
  </tr>
  <tr>
    <td>问卷结束日期</td>
    <td><input type="text" name="Survey_dateOver"   readOnly="" onClick="setDay(this);" value="<%=date()+100%>"></td>
    <td><span class="R">*</span> 问卷结束日期，到期后该问卷将不能接受</td>
  </tr>
  <tr>
   <td>问卷采用模板</td>
   <td>
       <select name="Survey_templet">
       <%
	   sql="select * from templet where Templet_column=3"
	   rs.open sql,conn,1,1
	   if rs.eof then 
	   I1 "<option value=""0"" selected>默认</option>"
	   else
	   while not rs.eof
		   if rs("Templet_default")<>true then
		   I1 "<option value="""&rs("Templet_id")&""">"&rs("Templet_name")&"</option>"
		   else
		   I1 "<option value="""&rs("Templet_id")&""" selected>"&rs("Templet_name")&"</option>"
		   end if
	   rs.movenext	   
	   wend
	   end if
	   rs.close
	   %>
    </select></td>
   <td><span class="R">*</span> 对问卷显示采用自定义模板</td>
  </tr>
  <tr>
    <td>需要用户输入个人资料</td>
    <td><input type="checkbox" name="Survey_needUserInfo" value="1"></td>
    <td><span class="R">*</span> 选中后，用户在回答问卷前需要填写个人资料</td>
  </tr>
  <tr>
    <td>记录单个用户问卷结果</td>
    <td><input type="checkbox" name="Survey_annal" value="1"></td>
    <td><span class="R">*</span> 选中后，程序将保存每一位回答者的问卷结果。</td>
  </tr>
  <tr>
    <td>应用问卷截断与跳转</td>
    <td><input type="checkbox" name="Survey_jdtz" value="1"></td>
    <td><span class="R">*</span> 应用该功能后，问卷将采用每页显示一个问题的方式显示。</td>
  </tr>
  <tr>
    <td>同一IP可重复提交</td>
    <td><input name="Survey_ipRepeat" type="checkbox" value="1" checked="checked"></td>
    <td>&nbsp;&nbsp;选中此项，同一IP可重复提交问卷</td>
  </tr>
  <tr>
    <td>公开此问卷调查</td>
    <td><input name="Survey_isOpen" type="checkbox" value="1" checked="checked"></td>
    <td><span class="R">*</span> 不公开的问卷，只能通过编号进行访问</td>
  </tr>
  <tr>
    <td width="">为问卷添加主题图片</td>
    <td width=""><input type="checkbox" name="Survey_isImg" value="1" onClick="SwitchHidden('hidden_isImg');">
	   <div id="hidden_isImg" style="display:none;">
		   <iframe src="uploadIndex.asp" frameborder="0" width="400" height="25"></iframe>
      </div>	</td>
    <td width=""> &nbsp;&nbsp;主题图片的格式必须为.jpg</td>
  </tr>
  
  <tr>
    <td>设置问卷密码</td>
    <td><input type="checkbox" name="Survey_isPassword" onClick="SwitchHidden('hidden_isPassword');">
	   <div id="hidden_isPassword" style="display:none;">
           输入密码：<input type="password" name="Survey_Password1" id="Survey_Password1"><br/>
           确认密码：<input type="password" name="Survey_Password2" id="Survey_Password2" onBlur="return CheckPassword('Survey_Password1','Survey_Password2','4');">
      </div>	</td>
    <td> &nbsp;&nbsp;选中此项，只有输入正确的密码才能完成问卷</td>
  </tr>
  
  <tr>
    <td>设置访问IP限制</td>
    <td>
	<input type="checkbox" name="Survry_IPLimit" onClick="SwitchHidden('hidden_ipLimit');">
<div id="hidden_ipLimit" style="display:none;">
该IP段内可以访问<input name="Survey_ipLimitKind" type="radio" value="bai"><br/>
该IP段内不可访问<input name="Survey_ipLimitKind" type="radio" value="hei"><br/>
IP段开始
<div style="border-width:1;border-color:balck;border-style:solid;width:165;font-size:9pt">
<input type=text name="ipSta1" maxlength="3" class="a3" onKeyUp="mask(this,'Sta')" onbeforepaste="mask_c()">.
<input type=text name="ipSta2" maxlength="3" class="a3" onKeyUp="mask(this,'Sta')" onbeforepaste="mask_c()">.
<input type=text name="ipSta3" maxlength="3" class="a3" onKeyUp="mask(this,'Sta')" onbeforepaste="mask_c()">.
<input type=text name="ipSta4" maxlength="3" class="a3" onKeyUp="mask(this,'Sta')" onbeforepaste="mask_c()">
</div>
<br/>
IP段结束
<div style="border-width:1;border-color:balck;border-style:solid;width:165;font-size:9pt">
<input type=text name="ipEnd1" maxlength="3" class="a3" onKeyUp="mask(this,'End')" onbeforepaste="mask_c()">.
<input type=text name="ipEnd2" maxlength="3" class="a3" onKeyUp="mask(this,'End')" onbeforepaste="mask_c()">.
<input type=text name="ipEnd3" maxlength="3" class="a3" onKeyUp="mask(this,'End')" onbeforepaste="mask_c()">.
<input type=text name="ipEnd4" maxlength="3" class="a3" onKeyUp="mask(this,'End')" onbeforepaste="mask_c()">
</div>

<br/>
<input type="hidden" name="Survey_ipStart">
<input type="hidden" name="Survey_ipEnd">
<input type="button" name="AddIP" value="添加" onClick="return AddIPAddress();">
<input type="button" name="DellIP" value="删除选定" onClick="return DellSelected();">
<input type="button" name="DellAllIP" value="清空" onClick="return DellAll();"><br/>
受限IP列表:
<select name="select" size="5" multiple="multiple" id="Survey_ipList">
</select>
<br/>
</div>	</td>
    <td>&nbsp;&nbsp;设置此项，对问卷访问者进行IP限制</td>
  </tr>  
  <tr>
    <td width="179">&nbsp;</td>
    <td>
	<div id="button">
	<input type="submit" name="submit" value="完成"><input type="reset" name="reset1" value="取消">
	</div>	</td>
    <td>&nbsp;</td>
  </tr>
</table>  
</form>
</div>
<div id="admin_surveyAdd_bottom">
</div>
</body>
</html>